package com.gw.quotes.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gw.quotes.R;
import com.gw.quotes.entity.business.Supplier;

public class Goods3Adapter extends BaseAdapter {

	private List<Supplier> list;
	private Context context;
	private int resource;
	private int width[];

	public Goods3Adapter(Context context, int layoutId, List<Supplier> list,
			int width[]) {
		this.context = context;
		this.resource = layoutId;
		this.list = list;
		this.width = width;
	}

	@Override
	public int getCount() {
		return this.list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Supplier supplier = list.get(position);
		if (convertView == null) {
			convertView = LayoutInflater.from(this.context).inflate(
					this.resource, parent, false);
		}
		TextView supplier_text = (TextView) convertView
				.findViewById(R.id.supplier_text);
		TextView contact_text = (TextView) convertView
				.findViewById(R.id.contact_text);
		TextView style_text = (TextView) convertView
				.findViewById(R.id.style_text);
		supplier_text.setText(supplier.getSuppliername());
		contact_text.setText(supplier.getLinkman());
		style_text.setText(supplier.getMobile());
		supplier_text.setWidth(width[0]);
		contact_text.setWidth(width[1]);
		style_text.setWidth(width[2]);
		return convertView;
	}
}
